﻿using System;
using System.Data.SqlClient;

namespace SpiderCore.Utility
{
    public static class CustomsLog
    {
        /// <summary>
        /// 写异常日志
        /// </summary>
        /// <param name="error"></param>
        /// <param name="detail"></param>
        public static void WriteExceptionErrorLog(string error, Exception detail, string remark = null)
        {
            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@DateTime", DateTime.Now.ToString()),
                    new SqlParameter("@Info", error),
                    new SqlParameter("@Detail", detail + remark)
                };
                SqlHelper.ExecuteNonQuery("insert into ErrorLog(DateTime,Info,Detail) values(@DateTime,@Info,@Detail)",
                    para);

            }
            catch (Exception)
            {

            }
        }

        public static void WriteInfoLog(string info, string detail)
        {
            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@DateTime", DateTime.Now.ToString()),
                    new SqlParameter("@Info", info),
                    new SqlParameter("@Detail", detail)
                };
                SqlHelper.ExecuteNonQuery("insert into ErrorLog(DateTime,Info,Detail) values(@DateTime,@Info,@Detail)",
                    para);

            }
            catch (Exception)
            {

            }
        }
    }
}
